package com.ddyx.rest;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ddyx.util.ExcelUtils;
import com.ddyx.util.RequestForm;
import com.ddyx.service.ICustomerContactService;
import com.ddyx.service.IEventAttenStoreService;
import com.ddyx.service.IUserService;
import com.ddyx.util.ResponseForm;
/**
 * @ClassName:  UserController   
 * @Description:用户信息controller  
 * @author: JiangShuai 
 * @date:   2018年1月3日 上午9:47:32     
 * @Copyright: 2018 dingdian.parllay.cn Inc. All rights reserved. 
 * 注意：本内容仅限于叮当一下(北京)信息技术有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
@Controller
@RequestMapping("/user")
public class UserController {
	
	@Resource
	IUserService userService;
	@Resource
	IEventAttenStoreService iEventAttenStoreService;
	@Resource
	ICustomerContactService iCustomerContactService;
	
	/**
	 * @Title: getUserInfo   
	 * @Description: 获取用户信息  
	 * @author: JiangShuai
	 * @param: @param param
	 * @param: @return      
	 * @return: ResponseForm
	 */
	@ResponseBody
	@RequestMapping(value="getUserInfo",method=RequestMethod.POST)
	public ResponseForm getUserInfo(@RequestBody RequestForm param) {
		return userService.getUserInfo(param);
	}
	/**
	 * @Title: updateUser   
	 * @Description: 修改用户电话/人脸识别图
	 * @author: JiangShuai
	 * @param: @param param
	 * @param: @return      
	 * @return: ResponseForm
	 */
	@ResponseBody
	@RequestMapping(value="updateUser",method=RequestMethod.POST)
	public ResponseForm updateUser(@RequestBody RequestForm param) {
		return userService.updateUser(param);
	}
	
	/**
	 * @Title: fileUpload   
	 * @Description: 上传图片->调用萝卜头->上传七牛->返回七牛路径
	 * @author: JiangShuai
	 * @param: @param req
	 * @param: @param response
	 * @param: @return
	 * @param: @throws Exception      
	 * @return: ResponseForm
	 */
	@ResponseBody
	@RequestMapping(value="fileUpload",method=RequestMethod.POST)
	public ResponseForm fileUpload(@RequestParam(value = "wxUid", required = true) String wxUid,
			@RequestParam(value = "wxSid", required = true) String wxSid,
			HttpServletRequest request,HttpServletResponse response) throws Exception {
		return userService.fileUpload(wxUid,wxSid,request, response);
	}
	/**
	 * @Title: getExcel   
	 * @Description: 导出商品的信息 
	 * @author: JiangShuai
	 * @param: @param request
	 * @param: @param response
	 * @param: @throws Exception      
	 * @return: void
	 */
	@SuppressWarnings("static-access")
	@RequestMapping(value="getExcel")
	public void getExcel(
			//@RequestParam(value = "excelname", required = true) String excelname,
			//@RequestParam(value = "url", required = true) String url,
			HttpServletRequest request,HttpServletResponse response) throws Exception {
		List<String> titlelist=new ArrayList<>();
		titlelist.add("goodsid");
		titlelist.add("文件夹名称");
		titlelist.add("goodspic");
		titlelist.add("goodsdesc");
		titlelist.add("soldon_time");
		String url="C:\\Users\\Administrator\\Desktop\\5+20180112";
		String excelname="wanbo";
		//String excelname="oushili";
		//String excelname="wanbowenjianjia";
		//String excelname="oushiliwenjianjia";
		//String url="C:\\Users\\Administrator\\Desktop\\goodsdaoru\\oushili";
		//List<List<String>> contentlist=new ExcelUtils().getfiles(url);
		List<List<String>> contentlist=new ExcelUtils().getfil(url);
		new ExcelUtils().getExcel(response, titlelist, contentlist, excelname);
	}
	
	/**
	 * @author lhj
	 * @description 获取用户关注过的门店
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="attenAllStore",method = RequestMethod.POST)
	public ResponseForm attenAllStore(@RequestBody RequestForm param) {
		return iEventAttenStoreService.attenAllStore(param);
	}
	
	/**
	 * @author lhj
	 * @description 获取用户所有专属导购
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="getAllGuide",method = RequestMethod.POST)
	public ResponseForm getAllGuide(@RequestBody RequestForm param) {
		return iCustomerContactService.getAllGuide(param);
	}
	
	
	/**
	 * @author wush
	 * @description 管理后台用户登录
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="login",method = RequestMethod.POST)
	public ResponseForm login(@RequestBody RequestForm param) {
		return userService.login(param);
	}
}
